package com.lms.admin.base.controller;

import com.lms.admin.base.service.ISysUserRoleService;
import com.lms.common.entity.SysUserRole;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/sysUserRole")
@RequiredArgsConstructor
@PreAuthorize("hasRole('ADMIN')")
@Tag(name="用户与角色关联相关请求")
public class SysUserRoleController {

    private final ISysUserRoleService baseService;

    @Operation(summary = "根据用户id获取其所属角色信息")
    @GetMapping("/getRoleByUserId/{userId}")
    public List<SysUserRole> getRoleByUserId(@PathVariable("userId") @Parameter(description = "用户id") Long userId) {
        return this.baseService.getRoleByUserId(userId);
    }
}
